package com.newtouch.bxzs.policy.service.impl;

import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.newtouch.bxzs.common.base.BaseErrorEnum;
import com.newtouch.bxzs.common.base.BaseException;
import com.newtouch.bxzs.common.base.em.CompanyParameterTypeEnum;
import com.newtouch.bxzs.common.base.em.DistributionTypeEnum;
import com.newtouch.bxzs.common.base.em.PolicyNatureType;
import com.newtouch.bxzs.common.base.em.SystemParamsEnum;
import com.newtouch.bxzs.common.base.util.CooperationCompanyUtils;
import com.newtouch.bxzs.common.base.util.RedisUtils;
import com.newtouch.bxzs.common.base.util.SendHttpRequestUtils;
import com.newtouch.bxzs.common.base.util.UserDetailUtil;
import com.newtouch.bxzs.policy.mapper.PolicyMapper;
import com.newtouch.bxzs.policy.model.bo.PreservationBO;
import com.newtouch.bxzs.policy.model.bo.family.*;
import com.newtouch.bxzs.policy.model.vo.*;
import com.newtouch.bxzs.policy.model.vo.family.*;
import com.newtouch.bxzs.policy.service.FamilyPolicyService;
import com.newtouch.bxzs.policy.util.QueryCriteriaUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

/**
 * 家庭单管理实现类
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2021/1/7 13:33</td>
 * <td>linhongxi</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author linhongxi
 * @version 1.0.0
 * @since 1.0.0
 */
@Service
public class FamilyPolicyServiceImpl implements FamilyPolicyService {

    @Resource
    private PolicyMapper policyMapper;

    @Autowired
    private RedisUtils redisUtils;

    @Autowired
    private CooperationCompanyUtils cooperationCompanyUtils;

    /**
     * 根据查询条件查询家庭单列表信息
     * @param familyPolicyVO 家庭单列表查询条件
     * @return 家庭单列表
     */
    @Override
    public IPage<FamilyPolicyBO> getFamilyPolicyList(FamilyPolicyVO familyPolicyVO) {
        //查询条件--日期验证
        QueryCriteriaUtils.queryValidationByDate(familyPolicyVO.getPolicyApplicationDate(),familyPolicyVO.getPolicyExpirationDate());
        //查询条件--保单号验证
        QueryCriteriaUtils.queryValidationByNumber(familyPolicyVO.getPolicyNumber());
        //查询条件--姓名验证
        QueryCriteriaUtils.queryValidationByName(familyPolicyVO.getPolicyHolderName(),null);
        //查询条件--投保人证件验证
        QueryCriteriaUtils.queryValidationByCertificate(familyPolicyVO.getPolicyHolderCertificateType(),familyPolicyVO.getPolicyHolderCertificateNumber());
        Page<FamilyPolicyBO> policyPage= new Page<>(familyPolicyVO.getCurrentPage(),
                familyPolicyVO.getPageSize());
        familyPolicyVO.setUserJobNumber(Objects.requireNonNull(UserDetailUtil.getUserDetail()).getUserJobNumber());
        return policyMapper.familyPolicyListBO(familyPolicyVO,policyPage,PolicyNatureType.FAMILY_POLICY_NATURE.getCode());
    }

    /**
     * 根据保单号查询家庭单详情信息
     * @param policyInfoVO 家庭单详情查询条件
     * @return 家庭单详情
     */
    @Override
    public FamilyPolicyBO getFamilyPolicyInfo(PolicyInfoVO policyInfoVO) {
        if(StringUtils.isEmpty(policyInfoVO.getPolicyNumber())){
            throw new BaseException(BaseErrorEnum.REQUEST_DATA_NULL.getResultCode(),BaseErrorEnum.REQUEST_DATA_NULL.getResultMsg());
        }
        policyInfoVO.setUserJobNumber(Objects.requireNonNull(UserDetailUtil.getUserDetail()).getUserJobNumber());
        SendHttpRequestUtils<PolicyInfoVO> sendHttpRequest = new SendHttpRequestUtils<>();
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.BANK.getCode())) {
            JSONObject response = sendHttpRequest.sendHttpRequestToJson(policyInfoVO, cooperationCompanyUtils.getCompanyUrl(policyInfoVO.getInsuranceCompanyName(),
                    CompanyParameterTypeEnum.FAMILY_POLICY_INFO.getCode()));
            Object data = response.get("data");
            if(!StringUtils.isEmpty(data)){
                return JSONObject.toJavaObject(JSONObject.parseObject(JSONUtil.toJsonStr(data)),FamilyPolicyBO.class);
            }

        }
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.INSURANCE.getCode())) {
            String url = redisUtils.get(SystemParamsEnum.FAMILY_POLICY_INFO.getCode());
            return JSON.toJavaObject(sendHttpRequest.sendHttpRequestToJson(policyInfoVO, url),FamilyPolicyBO.class);
        }
        return null;
    }

    /**
     * 根据保单号获取保全列表
     *
     * @param policyInfoPageVO 家庭单详情--保全列表查询条件
     *
     * @return 家庭单详情--保全列表
     */
    @Override
    public List<PreservationBO> getFamilyPolicyPreservation(PolicyInfoPageVO policyInfoPageVO){
        if(StringUtils.isEmpty(policyInfoPageVO.getPolicyNumber())){
            throw new BaseException(BaseErrorEnum.REQUEST_DATA_NULL.getResultCode(),BaseErrorEnum.REQUEST_DATA_NULL.getResultMsg());
        }
        policyInfoPageVO.setUserJobNumber(Objects.requireNonNull(UserDetailUtil.getUserDetail()).getUserJobNumber());
        //调用外部接口获取个单详情中的保全信息
        SendHttpRequestUtils<PolicyInfoPageVO> sendHttpRequest = new SendHttpRequestUtils<>();
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.BANK.getCode())) {
            JSONObject response = sendHttpRequest.sendHttpRequestToJson(policyInfoPageVO, cooperationCompanyUtils.getCompanyUrl(policyInfoPageVO.getInsuranceCompanyName(),
            CompanyParameterTypeEnum.FAMILY_POLICY_INFO_PRESERVATION.getCode()));
            Object data = response.get("data");
            if(data != null){
                String result = JSONUtil.toJsonStr(data);
                if(!StringUtils.isEmpty(data)){
                    return JSON.parseArray(result,PreservationBO.class);
                }
            }
        }
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.INSURANCE.getCode())) {
            String url = redisUtils.get(SystemParamsEnum.FAMILY_POLICY_INFO_PRESERVATION.getCode());
            return JSONObject.parseArray(sendHttpRequest.sendHttpRequestToArray(policyInfoPageVO,url).toJSONString(),PreservationBO.class);
        }
        return null;
    }

    /**
     * 根据保单号获取理赔列表
     *
     * @param policyInfoPageVO 家庭单详情--理赔列表查询条件
     *
     * @return 家庭单详情--理赔列表
     */
    @Override
    public List<FamilyClaimsBO> getPolicyClaims(PolicyInfoPageVO policyInfoPageVO){
        if(StringUtils.isEmpty(policyInfoPageVO.getPolicyNumber())){
            throw new BaseException(BaseErrorEnum.REQUEST_DATA_NULL.getResultCode(),BaseErrorEnum.REQUEST_DATA_NULL.getResultMsg());
        }
        policyInfoPageVO.setUserJobNumber(Objects.requireNonNull(UserDetailUtil.getUserDetail()).getUserJobNumber());
        SendHttpRequestUtils<PolicyInfoPageVO> sendHttpRequest = new SendHttpRequestUtils<>();
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.BANK.getCode())) {
            JSONObject response = sendHttpRequest.sendHttpRequestToJson(policyInfoPageVO, cooperationCompanyUtils.getCompanyUrl(policyInfoPageVO.getInsuranceCompanyName(),
                    CompanyParameterTypeEnum.FAMILY_POLICY_INFO_CLAIMS.getCode()));
            Object data = response.get("data");
            if(data != null){
                String result = JSONUtil.toJsonStr(data);
                if(!StringUtils.isEmpty(data)){
                    return JSON.parseArray(result,FamilyClaimsBO.class);
                }
            }
        }
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.INSURANCE.getCode())) {
            String url = redisUtils.get(SystemParamsEnum.FAMILY_POLICY_INFO_CLAIMS.getCode());
            return JSONObject.parseArray(sendHttpRequest.sendHttpRequestToArray(policyInfoPageVO, url).toJSONString(),FamilyClaimsBO.class);
        }
        return null;
    }

    /**
     * 根据保单号获取家庭单人员清单列表
     *
     * @param policyUserListVO 家庭单详情--人员清单列表查询条件
     *
     * @return 家庭单详情--人员清单列表
     */
    @Override
    public List<PolicyUserListBO> getFamilyPolicyUserList(PolicyUserListVO policyUserListVO){
        if(StringUtils.isEmpty(policyUserListVO.getPolicyNumber())){
            throw new BaseException(BaseErrorEnum.REQUEST_DATA_NULL.getResultCode(),BaseErrorEnum.REQUEST_DATA_NULL.getResultMsg());
        }
        policyUserListVO.setUserJobNumber(Objects.requireNonNull(UserDetailUtil.getUserDetail()).getUserJobNumber());
        //调用外部接口查询家庭单详情人员清单列表
        SendHttpRequestUtils<PolicyUserListVO> sendHttpRequest = new SendHttpRequestUtils<>();
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.BANK.getCode())) {
            JSONObject response = sendHttpRequest.sendHttpRequestToJson(policyUserListVO, cooperationCompanyUtils.getCompanyUrl(policyUserListVO.getInsuranceCompanyName(),
                    CompanyParameterTypeEnum.FAMILY_POLICY_INFO_USER.getCode()));
            Object data = response.get("data");
            if(data != null){
                String result = JSONUtil.toJsonStr(data);
                if(!StringUtils.isEmpty(data)){
                    return JSON.parseArray(result,PolicyUserListBO.class);
                }
            }
        }
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.INSURANCE.getCode())) {
            String url = redisUtils.get(SystemParamsEnum.FAMILY_POLICY_INFO_USER.getCode());
            return JSONObject.parseArray(sendHttpRequest.sendHttpRequestToArray(policyUserListVO, url).toJSONString(),PolicyUserListBO.class);
        }
        return null;
    }

    /**
     * 根据查询条件获取新契约进度列表
     *
     * @param familyPolicyNewContractVO 家庭单新契约进度列表查询条件
     *
     * @return 家庭单新契约进度列表
     */
    @Override
    public List<FamilyPolicyNewContractBO> getNewContractListByFamilyPolicy(FamilyPolicyNewContractVO familyPolicyNewContractVO){
        //查询条件--日期验证
        QueryCriteriaUtils.queryValidationByDate(familyPolicyNewContractVO.getPolicyApplicationDate(),familyPolicyNewContractVO.getPolicyExpirationDate());
        //查询条件--保单号验证
        QueryCriteriaUtils.queryValidationByNumber(familyPolicyNewContractVO.getPolicyApplicationNumber());
        //查询条件--姓名验证
        QueryCriteriaUtils.queryValidationByName(familyPolicyNewContractVO.getPolicyHolderName(),null);
        //查询条件--投保人证件验证
        QueryCriteriaUtils.queryValidationByCertificate(familyPolicyNewContractVO.getPolicyHolderCertificateType(),familyPolicyNewContractVO.getPolicyHolderCertificateNumber());
        familyPolicyNewContractVO.setUserJobNumber(Objects.requireNonNull(UserDetailUtil.getUserDetail()).getUserJobNumber());
        //调用外部接口获取新契约保单信息
        SendHttpRequestUtils<FamilyPolicyNewContractVO> sendHttpRequest = new SendHttpRequestUtils<>();
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.BANK.getCode())) {
            JSONObject response = sendHttpRequest.sendHttpRequestToJson(familyPolicyNewContractVO, cooperationCompanyUtils.getCompanyUrl(familyPolicyNewContractVO.getInsuranceCompanyName(),
            CompanyParameterTypeEnum.FAMILY_POLICY_NEW_CONTRACT.getCode()));
            Object data = response.get("data");
            if(data != null){
                String result = JSONUtil.toJsonStr(data);
                if(!StringUtils.isEmpty(data)){
                    return JSON.parseArray(result,FamilyPolicyNewContractBO.class);
                }
            }
        }
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.INSURANCE.getCode())) {
            String url = redisUtils.get(SystemParamsEnum.FAMILY_POLICY_NEW_CONTRACT.getCode());
            return  JSONArray.parseArray(sendHttpRequest.sendHttpRequestToArray(familyPolicyNewContractVO, url).toJSONString(),FamilyPolicyNewContractBO.class);
        }
        return null;
    }

    /**
     * 根据保单号获取新契约进度详情
     *
     * @param policyNewContractInfoVO 家庭单新契约进度详情查询条件
     *
     * @return 家庭单新契约进度详情
     */
    @Override
    public FamilyPolicyNewContractBO getNewContractInfoByFamilyPolicy(PolicyNewContractInfoVO policyNewContractInfoVO){
        if(StringUtils.isEmpty(policyNewContractInfoVO.getPolicyApplicationNumber())){
            throw new BaseException(BaseErrorEnum.REQUEST_DATA_NULL.getResultCode(),BaseErrorEnum.REQUEST_DATA_NULL.getResultMsg());
        }
        policyNewContractInfoVO.setUserJobNumber(Objects.requireNonNull(UserDetailUtil.getUserDetail()).getUserJobNumber());
        //调用外部接口获取家庭单新契约进度详情信息
        SendHttpRequestUtils<PolicyNewContractInfoVO> sendHttpRequest = new SendHttpRequestUtils<>();
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.BANK.getCode())) {
            JSONObject response= sendHttpRequest.sendHttpRequestToJson(policyNewContractInfoVO, cooperationCompanyUtils.getCompanyUrl(policyNewContractInfoVO.getInsuranceCompanyName(),
                    CompanyParameterTypeEnum.FAMILY_POLICY_NEW_CONTRACT_INFO.getCode()));
            Object data = response.get("data");
            if(!StringUtils.isEmpty(data)){
                return JSONObject.toJavaObject(JSONObject.parseObject(JSONUtil.toJsonStr(data)),FamilyPolicyNewContractBO.class);
            }
        }
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.INSURANCE.getCode())) {
            String url = redisUtils.get(SystemParamsEnum.FAMILY_POLICY_NEW_CONTRACT_INFO.getCode());
            return  JSON.toJavaObject(sendHttpRequest.sendHttpRequestToJson(policyNewContractInfoVO, url),FamilyPolicyNewContractBO.class);
        }
        return null;
    }
    /**
     * 根据保单号获取家庭单新契约详情人员清单列表
     *
     * @param familyPolicyNewContractInfoVO 家庭单新契约进度详情--人员清单列表查询条件
     *
     * @return 家庭单新契约进度详情--人员清单列表
     */
    @Override
    public List<PolicyUserListBO> getNewContractUserListByFamilyPolicy(FamilyPolicyNewContractInfoVO familyPolicyNewContractInfoVO){
        if(StringUtils.isEmpty(familyPolicyNewContractInfoVO.getPolicyApplicationNumber())){
            throw new BaseException(BaseErrorEnum.REQUEST_DATA_NULL.getResultCode(),BaseErrorEnum.REQUEST_DATA_NULL.getResultMsg());
        }
        familyPolicyNewContractInfoVO.setUserJobNumber(Objects.requireNonNull(UserDetailUtil.getUserDetail()).getUserJobNumber());
        SendHttpRequestUtils<FamilyPolicyNewContractInfoVO> sendHttpRequest = new SendHttpRequestUtils<>();
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.BANK.getCode())) {
            JSONObject response = sendHttpRequest.sendHttpRequestToJson(familyPolicyNewContractInfoVO, cooperationCompanyUtils.getCompanyUrl(familyPolicyNewContractInfoVO.getInsuranceCompanyName(),
                    CompanyParameterTypeEnum.FAMILY_POLICY_NEW_CONTRACT_INFO_USER.getCode()));
            Object data = response.get("data");
            if(data != null){
                String result = JSONUtil.toJsonStr(data);
                if(!StringUtils.isEmpty(data)){
                    return JSON.parseArray(result,PolicyUserListBO.class);
                }
            }
        }
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.INSURANCE.getCode())) {
            String url = redisUtils.get(SystemParamsEnum.FAMILY_POLICY_NEW_CONTRACT_INFO_USER.getCode());
            return JSONObject.parseArray(sendHttpRequest.sendHttpRequestToArray(familyPolicyNewContractInfoVO, url).toJSONString(),PolicyUserListBO.class);
        }
        return null;
    }

    /**
     * 根据查询条件获取保全进度列表
     *
     * @param familyPreservationVO 家庭单保全进度列表查询条件
     *
     * @return 家庭单保全进度列表
     */
    @Override
    public List<FamilyPreservationProgressInfoBO> getPreservationListByFamilyPolicy(FamilyPreservationVO familyPreservationVO){
        //查询条件--保单号验证
        QueryCriteriaUtils.queryValidationByNumber(familyPreservationVO.getPolicyNumber());
        //查询条件--保全受理号验证
        QueryCriteriaUtils.queryValidationByNumber(familyPreservationVO.getPreservationAcceptanceNumber());
        //查询条件--姓名验证
        QueryCriteriaUtils.queryValidationByName(familyPreservationVO.getPolicyHolderName(),null);
        //查询条件--投保人证件验证
        QueryCriteriaUtils.queryValidationByCertificate(familyPreservationVO.getPolicyHolderCertificateType(),familyPreservationVO.getPolicyHolderCertificateNumber());
        familyPreservationVO.setUserJobNumber(Objects.requireNonNull(UserDetailUtil.getUserDetail()).getUserJobNumber());
        //调用外部接口获取保全进度列表信息
        SendHttpRequestUtils<FamilyPreservationVO> sendHttpRequest = new SendHttpRequestUtils<>();
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.BANK.getCode())) {
            JSONObject response = sendHttpRequest.sendHttpRequestToJson(familyPreservationVO,cooperationCompanyUtils.getCompanyUrl(familyPreservationVO.getInsuranceCompanyName(),
                    CompanyParameterTypeEnum.FAMILY_POLICY_PRESERVATION.getCode()));
            Object data = response.get("data");
            if(data != null){
                String result = JSONUtil.toJsonStr(data);
                if(!StringUtils.isEmpty(data)){
                    return JSON.parseArray(result,FamilyPreservationProgressInfoBO.class);
                }
            }
        }
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.INSURANCE.getCode())) {
            String url = redisUtils.get(SystemParamsEnum.FAMILY_POLICY_PRESERVATION.getCode());
            return JSONObject.parseArray(sendHttpRequest.sendHttpRequestToArray(familyPreservationVO, url).toJSONString(),FamilyPreservationProgressInfoBO.class);
        }
        return null;
    }
    /**
     * 根据保单号获取保全进度详情
     *
     * @param preservationProgressInfoVO 家庭单保全进度详情查询条件
     *
     * @return 家庭单保全进度详情
     */
    @Override
    public FamilyPreservationProgressInfoBO getPreservationInfoByFamilyPolicy(PreservationProgressInfoVO preservationProgressInfoVO){
        if(StringUtils.isEmpty(preservationProgressInfoVO.getPreservationAcceptanceNumber())){
            throw new BaseException(BaseErrorEnum.REQUEST_DATA_NULL.getResultCode(),BaseErrorEnum.REQUEST_DATA_NULL.getResultMsg());
        }
        //获取用户工号
        preservationProgressInfoVO.setUserJobNumber(Objects.requireNonNull(UserDetailUtil.getUserDetail()).getUserJobNumber());
        //调用外部接口获取家庭单保全进度详情信息
        SendHttpRequestUtils<PreservationProgressInfoVO> sendHttpRequest = new SendHttpRequestUtils<>();
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.BANK.getCode())) {
            JSONObject response = sendHttpRequest.sendHttpRequestToJson(preservationProgressInfoVO, cooperationCompanyUtils.getCompanyUrl(preservationProgressInfoVO.getInsuranceCompanyName(), CompanyParameterTypeEnum.FAMILY_POLICY_PRESERVATION_INFO.getCode()));
            Object data = response.get("data");
            if(!StringUtils.isEmpty(data)){
                return JSONObject.toJavaObject(JSONObject.parseObject(JSONUtil.toJsonStr(data)),FamilyPreservationProgressInfoBO.class);
            }
        }
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.INSURANCE.getCode())) {
            String url = redisUtils.get(CompanyParameterTypeEnum.FAMILY_POLICY_PRESERVATION_INFO.getCode());
            return JSON.toJavaObject(sendHttpRequest.sendHttpRequestToJson(preservationProgressInfoVO, url),FamilyPreservationProgressInfoBO.class);
        }
        return null;
    }

    /**
     * 根据查询条件获取理赔进度列表
     *
     * @param familyClaimsVO 家庭单理赔进度列表查询条件
     *
     * @return 家庭单理赔进度列表
     */
    @Override
    public List<FamilyClaimsBO> getClaimsProgressListByFamilyPolicy(FamilyClaimsVO familyClaimsVO){
        //查询条件--日期验证
        QueryCriteriaUtils.queryValidationByDate(familyClaimsVO.getApplicationStartDate(),familyClaimsVO.getApplicationDeadline());
        //查询条件--保单号验证
        QueryCriteriaUtils.queryValidationByNumber(familyClaimsVO.getPolicyNumber());
        //查询条件--报案号验证
        QueryCriteriaUtils.queryValidationByNumber(familyClaimsVO.getReportNumber());
        //查询条件--赔案号验证
        QueryCriteriaUtils.queryValidationByNumber(familyClaimsVO.getClaimsNumber());
        //查询条件--姓名验证
        QueryCriteriaUtils.queryValidationByName(familyClaimsVO.getPolicyHolderName(),null);
        //查询条件--投保人证件验证
        QueryCriteriaUtils.queryValidationByCertificate(familyClaimsVO.getPolicyHolderCertificateType(),familyClaimsVO.getPolicyHolderCertificateNumber());
        //获取用户工号
        familyClaimsVO.setUserJobNumber(Objects.requireNonNull(UserDetailUtil.getUserDetail()).getUserJobNumber());
        //调用外部接口获取理赔进度信息
        SendHttpRequestUtils<FamilyClaimsVO> sendHttpRequest = new SendHttpRequestUtils<>();
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.BANK.getCode())) {
            JSONObject response= sendHttpRequest.sendHttpRequestToJson(familyClaimsVO, cooperationCompanyUtils.getCompanyUrl(familyClaimsVO.getInsuranceCompanyName(), CompanyParameterTypeEnum.FAMILY_POLICY_CLAIMS.getCode()));
            Object data = response.get("data");
            if(data != null){
                String result = JSONUtil.toJsonStr(data);
                if(!StringUtils.isEmpty(data)){
                    return JSON.parseArray(result,FamilyClaimsBO.class);
                }
            }
        }
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.INSURANCE.getCode())) {
            String url = redisUtils.get(CompanyParameterTypeEnum.FAMILY_POLICY_CLAIMS.getCode());
            return JSONObject.parseArray(sendHttpRequest.sendHttpRequestToArray(familyClaimsVO, url).toJSONString(),FamilyClaimsBO.class);
        }
        return null;
    }

    /**
     * 根据查询条件获取满期保单列表
     *
     * @param familyExpirationPolicyVO 家庭单满期列表查询条件
     *
     * @return 家庭单满期列表
     */
    @Override
    public List<FamilyExpirationPolicyBO> getExpirationPolicyListByFamilyPolicy(FamilyExpirationPolicyVO familyExpirationPolicyVO){

        //查询条件--保单号验证
        QueryCriteriaUtils.queryValidationByNumber(familyExpirationPolicyVO.getPolicyNumber());
        //查询条件--姓名验证
        QueryCriteriaUtils.queryValidationByName(familyExpirationPolicyVO.getPolicyHolderName(),null);
        //查询条件--投保人证件验证
        QueryCriteriaUtils.queryValidationByCertificate(familyExpirationPolicyVO.getPolicyHolderCertificateType(),familyExpirationPolicyVO.getPolicyHolderCertificateNumber());
        //获取当前登录人信息
        familyExpirationPolicyVO.setUserJobNumber(Objects.requireNonNull(UserDetailUtil.getUserDetail()).getUserJobNumber());
        //调用外部接口获取满期保单数据
        SendHttpRequestUtils<FamilyExpirationPolicyVO> sendHttpRequest = new SendHttpRequestUtils<>();
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.BANK.getCode())) {
            JSONObject response = sendHttpRequest.sendHttpRequestToJson(familyExpirationPolicyVO, cooperationCompanyUtils.getCompanyUrl(familyExpirationPolicyVO.getInsuranceCompanyName(), CompanyParameterTypeEnum.FAMILY_POLICY_EXPIRATION.getCode()));
            Object data = response.get("data");
            if(data != null){
                String result = JSONUtil.toJsonStr(data);
                if(!StringUtils.isEmpty(data)){
                    return JSON.parseArray(result,FamilyExpirationPolicyBO.class);
                }
            }
        }
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.INSURANCE.getCode())) {
            String url = redisUtils.get(CompanyParameterTypeEnum.FAMILY_POLICY_EXPIRATION.getCode());
            return JSONObject.parseArray(sendHttpRequest.sendHttpRequestToArray(familyExpirationPolicyVO, url).toJSONString(),FamilyExpirationPolicyBO.class);
        }
        return null;
    }

    /**
     * 根据查询条件获取续期保单列表
     *
     * @param familyRenewalPolicyVO 家庭单续期列表查询条件
     *
     * @return 家庭单续期列表
     */
    @Override
    public List<FamilyRenewalPolicyBO> getRenewalPolicyListByFamilyPolicy(FamilyRenewalPolicyVO familyRenewalPolicyVO){

        //查询条件--保单号验证
        QueryCriteriaUtils.queryValidationByNumber(familyRenewalPolicyVO.getPolicyNumber());
        //查询条件--姓名验证
        QueryCriteriaUtils.queryValidationByName(familyRenewalPolicyVO.getPolicyHolderName(),null);
        //查询条件--投保人证件验证
        QueryCriteriaUtils.queryValidationByCertificate(familyRenewalPolicyVO.getPolicyHolderCertificateType(),familyRenewalPolicyVO.getPolicyHolderCertificateNumber());
        //获取当前登录人信息
        familyRenewalPolicyVO.setUserJobNumber(Objects.requireNonNull(UserDetailUtil.getUserDetail()).getUserJobNumber());
        //调用外部接口查询续期保单列表
        SendHttpRequestUtils<FamilyRenewalPolicyVO> sendHttpRequest = new SendHttpRequestUtils<>();
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.BANK.getCode())) {
            JSONObject response = sendHttpRequest.sendHttpRequestToJson(familyRenewalPolicyVO, cooperationCompanyUtils.getCompanyUrl(familyRenewalPolicyVO.getInsuranceCompanyName(),
                    CompanyParameterTypeEnum.FAMILY_POLICY_RENEWAL.getCode()));
            Object data = response.get("data");
            if(data != null){
                String result = JSONUtil.toJsonStr(data);
                if(!StringUtils.isEmpty(data)){
                    return JSON.parseArray(result,FamilyRenewalPolicyBO.class);
                }
            }
        }
        if (redisUtils.get(SystemParamsEnum.BANKING_OR_INSURANCE.getCode()).equals(DistributionTypeEnum.INSURANCE.getCode())) {
            String url = redisUtils.get(CompanyParameterTypeEnum.FAMILY_POLICY_RENEWAL.getCode());
            return JSONObject.parseArray(sendHttpRequest.sendHttpRequestToArray(familyRenewalPolicyVO, url).toJSONString(),FamilyRenewalPolicyBO.class);
        }
        return null;
    }

}
